package com.hsc.www.exchangeType.topic;

import com.alibaba.fastjson.JSONObject;
import com.hsc.www.User;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserSender {
    @Autowired
    private RabbitTemplate template;

    public void send(String routingKey, User user) {
        template.convertAndSend(Config.CAT_EXCHANGE, routingKey, user);
        System.out.println("发送：routingKey=" + routingKey + "   " + JSONObject.toJSONString(user));

    }

}